package com.pms.servlet;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.pms.entity.Ideacomment;
import com.pms.entity.Ideas;
import com.pms.service.IdeaCommentService;
import com.pms.service.IdeaService;
import com.pms.util.GetSession;

public class ToIdeashow extends HttpServlet {

	private static final long serialVersionUID = 1L;

	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		response.setCharacterEncoding("utf-8");
		String idid=request.getParameter("ideaId");
		

		if(idid==null){
			Ideas ideas = (Ideas)GetSession.getSession(request).getAttribute("idea");
			idid=ideas.getIdeaid();
			
			Ideas idea=new IdeaService().findid(idid);
			System.out.println(idea+"ssssssssss");
			GetSession.getSession(request).setAttribute("idea", idea);
			
			List<Ideacomment> icList=new IdeaCommentService().findByIdeaid(idid);
			GetSession.getSession(request).setAttribute("icList", icList);
			
		}else{
			
			Ideas idea=new IdeaService().findid(idid);
			System.out.println(idea+"ssssssssss");
			GetSession.getSession(request).setAttribute("idea", idea);
			
			List<Ideacomment> icList=new IdeaCommentService().findByIdeaid(idid);
			GetSession.getSession(request).setAttribute("icList", icList);
		}
		
		
		request.getRequestDispatcher("/WEB-INF/ideashow.jsp").forward(request, response);
	}

}
